/*
 * @Author: your name
 * @Date: 2021-04-17 17:15:06
 * @LastEditTime: 2021-05-31 15:51:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \egg-demo\database\migrations\20210417091506-init-users.js
 */
'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, DATE, STRING, UUIDV4, UUID } = Sequelize;
    await queryInterface.createTable('users', {
      name: {
        type: STRING(30),
        allowNull: true,
        defaultValue: null,
        primaryKey: false,
        autoIncrement: false,
        comment: null,
        field: 'name',
      },
      id_name: {
        type: STRING(18),
        allowNull: false,
        comment:'证件号'
      },
      password: {
        type: STRING,
        comment: '密码'
      },
      age: {
        type: STRING(3),
        comment: '年龄',
        allowNull: true,
      },
      gender: {
        type: STRING(1),
        defaultValue: 'F',
        comment: '性别',
        allowNull: true,
      },
      province_code: {
        type: STRING(8),
        allowNull: true,
        comment: '省-code'
      },
      city_code: {
        type: STRING(8),
        allowNull: true,
        comment: '市-code'
      },
      county_code: {
        type: STRING(8),
        allowNull: true,
        comment: '区-code'
      },
      address: {
        type: STRING(128),
        allowNull: true,
        comment: '地址'
      },
      uuid: {
        type: UUID,
        defaultValue: UUIDV4,
        allowNull: false,
        primaryKey: true
      },
      created_at: {
        type: DATE,
        allowNull: true,
        defaultValue: null,
        primaryKey: false,
        autoIncrement: false,
        comment: null,
        field: 'created_at',
      },
      updated_at: {
        type: DATE,
        allowNull: true,
        defaultValue: null,
        primaryKey: false,
        autoIncrement: false,
        comment: null,
        field: 'updated_at',
      },
    });
  },

  down: async queryInterface => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('users');
  },
};
